package 算法.leetcode.labuladong.数组和链表;

/**
 * https://leetcode.cn/problems/range-addition/
 * 370
 *
 * @author lchenglong
 * @date 2022/6/15
 */
public class 区间加法 {
    class Solution{
        int[] getModifyArray(int length,int[][] updates){
            // 初始化数组
            int[] nums = new int[length];
            // 构造差分数组
            Difference df = new Difference(nums);
            for (int[] update:updates){
                int i = update[0];
                int j = update[1];
                int val = update[2];
                df.increment(i,j,val);
            }
            return df.result();
        }
    }
}
